<!DOCTYPE html>
<html class="x-admin-sm">
{include file="common/static" /}
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                  <div class="layui-form-item">
                      <label for="username" class="layui-form-label">
                          <span class="x-red">*</span>班次
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="classes" name="username" required="" lay-verify="required"
                          autocomplete="off" class="layui-input">
                      </div>

                  </div>
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>开始
                        </label>
                        <div class="layui-input-inline">
                            <input class="layui-input" placeholder="开始日" name="start" id="start">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>结束
                        </label>
                        <div class="layui-input-inline">
                            <input class="layui-input" placeholder="截止日" name="end" id="end">
                        </div>
                    </div>


                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" type="button" onclick="adds()">
                          增加
                      </button>
                  </div>
              </form>
            </div>
        </div>

    </body>
<script>
    layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
                ,type: 'time'
                ,value: '00:00:00'
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
                ,type: 'time'
                ,value: '23:00:00'
            });
        });
    function adds(){
        $.ajax({
            type:"post",
            url: "{:url('home/classe/adds')}",
            data: {
                classe:$('#classes').val(),
                start:$('#start').val(),
                end:$('#end').val(),
            },
            success: function(data){
                console.log(data);
                toastr.error(data.msg);
                if(data.code == 100){
                    setTimeout(function () {
                        layer.closeAll();
                        parent.location.reload();
                    },1500);
                }
            }});
    }
</script>

</html>
